<template>
  <div>
    <div>
      <van-row >
        <van-col span="8" style="line-height: 50px;"><van-icon name="manager-o" /></van-col>
        <!--搜索框-->
        <van-col span="8"><van-search v-model="value" placeholder="搜索" /></van-col>
        <van-col span="8" style="line-height: 50px;">搜索</van-col>
      </van-row>

    </div>


    <!--轮播图-->
    <van-swipe :autoplay="2000">
      <van-swipe-item v-for="(image, index) in images" :key="index">
        <img v-lazy="image" width="100%" height="250" />
      </van-swipe-item>
    </van-swipe>

    <!--通知栏-->
    <van-notice-bar
      left-icon="volume-o"
      scrollable
      text="关于2022年深化纠正'四风'和作风纪律专项活动。"
    />
    <van-tabbar v-model="active" @change="onChange" route>
      <van-tabbar-item icon="home-o" name="基层党建" replace to="/a1">基层党建</van-tabbar-item>

      <van-tabbar-item icon="search" name="教育培训" replace to="/education">教育培训</van-tabbar-item>

      <van-tabbar-item icon="friends-o" name="首页" replace to="/">首页</van-tabbar-item>

      <van-tabbar-item icon="setting-o" name="意识形态" replace to="/a4">意识形态</van-tabbar-item>

      <van-tabbar-item icon="search" name="群团天地" replace to="/a5">群团天地</van-tabbar-item>
    </van-tabbar>

    <!---->
    <!--    意识形态内容-->
    <van-tabs >
      <van-tab title="核心价值观">
<!--        下拉刷新-->
        <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
<!--          list内容-->
          <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
<!--        <van-cell v-for="item in list" :key="item" :title="item" />-->
            <div v-for="item in list" @click="fun(item.id)" style="border:1px solid red ;height: 100px;">
<!--              标题-->
              <div>
                <span style="line-height: 40px; font-family:新宋体;">{{item.title}}</span>
              </div>
<!--              来源-->
              <div>
                <span style="font-size: 10px; position: absolute; right: 20px;">来源:{{item.source}}</span>
              </div>
<!--              时间-->
              <div>
                <span style="font-size: 10px;">{{item.publishTime}}</span>
              </div>
            </div>
          </van-list>
        </van-pull-refresh>
      </van-tab>


      <van-tab title="企业文化">
        <!--        下拉刷新-->
        <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
          <!--          list内容-->
          <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="aoad">
            <!--        <van-cell v-for="item in list" :key="item" :title="item" />-->
            <div v-for="item in list1" @click="fund(item.businessId)" style="border:1px solid red ;height: 100px;">
              <!--              标题-->
              <div>
                <span style="line-height: 40px; font-family:新宋体;">{{item.businessTitle}}</span>
              </div>
              <!--              来源-->
              <div>
                <span style="font-size: 10px; position: absolute; right: 20px;">来源:{{item.businessSource}}</span>
              </div>
              <!--              时间-->
              <div>
                <span style="font-size: 10px;">{{item.businessPublishTime}}</span>
              </div>
            </div>
          </van-list>
        </van-pull-refresh>
      </van-tab>

      <van-tab title="调查问卷" route replace to="/question">

      </van-tab>
    </van-tabs>


  </div>
</template>

<script>
import {Notify} from "vant";
import axios from 'axios'
export default {
  name: "a4.vue",
  data(){
    return{
      active:'',
      value :"",
      images: [
        'http://rhs5roj8q.hb-bkt.clouddn.com/%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202022-09-23%20163919.png',
        'https://img.yzcdn.cn/vant/apple-2.jpg',
      ],
      list: [],
      list1: [],
      loading: false,
      finished: false,
    }
  },
  methods:{
    que(){
      this.$router.push({name:"question"});
    },
    //跳转页面到新闻详情页
    fun(id){
      this.$router.push({name:"newsDetail",params:{id:id}});
    },
    fund(businessId){
      this.$router.push({name:"business",params:{id:businessId}});
    },
    onChange(name) {
      Notify({ type: 'primary', message: name });
    },
    //查询新闻列表
    onLoad() {
      // 异步更新数据
      // setTimeout 仅做示例，真实场景中一般为 ajax 请求
      setTimeout(() => {
        axios.post("http://localhost:7000/xwen/findTitle").then(res=>{

            this.list=res.data.data;

        });
        // 加载状态结束
        this.loading = false;
        // 数据全部加载完成
          this.finished = true;
      }, 1000);
    },
    aoad() {
      //alert("进入方法");
      // 异步更新数据
      // setTimeout 仅做示例，真实场景中一般为 ajax 请求
      setTimeout(() => {
        axios.post("http://localhost:7000/bus/findAllBus").then(res=>{
          this.list1=res.data.data;

        });
        // 加载状态结束
        this.loading = false;
        // 数据全部加载完成
        this.finished = true;
      }, 1000);
    },
  },
  mounted () {
    this.aoad();
  }
}
</script>

<style scoped>
.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 50px;
  line-height: 50px;
  text-align: center;
  background-color: #39a9ed;
}
</style>
